package course;
import java.util.ArrayList;
import java.util.List;
public class Teacher {
    private int teacherId;
    private String name;
    private String gender;
    private List<Course> courses;  // 修改为课程列表，支持多门课程
    private String phoneNumber;

    // 构造方法
    public Teacher(int teacherId, String name, String gender, String phoneNumber) {
        this.teacherId = teacherId;
        this.name = name;
        this.gender = gender;
        this.phoneNumber = phoneNumber;
        this.courses = new ArrayList<>();  // 初始化课程列表
    }

    // 添加课程
    public void addCourse(Course course) {
        this.courses.add(course);
        course.setTeacher(this);
    }

    // 教师开课方法，展示所有开设的课程
    public void openCourses() {
        System.out.println("\n教师" + name + "（联系电话：" + phoneNumber + "）开设了以下课程：");
        for (Course course : courses) {
            System.out.println("课程编号：" + course.getCourseId() + "，课程名称：" + course.getCourseName() +
                    "，学分：" + course.getCredits() + "，时间：" + course.getTime() +
                    "，地点：" + course.getLocation());
        }
    }

    // getter和setter方法
    public int getTeacherId() {
        return teacherId;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }

    public List<Course> getCourses() {
        return courses;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
}
